<!--  -->
<template>
  <div class="container">
    <el-form ref="form" :inline="true" :model="form" :rules="rules" disabled>
      <el-tabs v-model="activeName" style="padding-left:30px">
        <el-tab-pane label="基本信息" name="first">
          <div class="section">
            <h2 class="title">基本信息</h2>
            <ul class="info">
              <li class="list-item">
                <div class="tip">
                  <span class="must">*</span> 充值卡号：
                </div>
                <div class="detail">
                  <el-input v-model="form.bank_number" :maxlength="42" placeholder="请输入内容" />
                </div>
              </li>
              <li class="list-item">
                <div class="tip">
                  <span class="must">*</span> 充值银行：
                </div>
                <div class="detail">
                  <el-input v-model="form.bank_name" :maxlength="42" placeholder="请输入内容" />
                </div>
              </li>
              <li class="list-item">
                <div class="tip">
                  <span class="must">*</span> 户名：
                </div>
                <div class="detail">
                  <el-input v-model="form.bank_user_name" :maxlength="42" placeholder="请输入内容" />
                </div>
              </li>
              <li class="list-item">
                <div class="tip">
                  <span class="must">*</span> 充值金额：
                </div>
                <div class="detail">
                  <el-input v-model="form.money" :maxlength="42" placeholder="请输入内容" />
                </div>
              </li>
              <li class="list-item">
                <div class="tip">
                  <span class="must">*</span> 充值时间：
                </div>
                <div class="detail">
                  <el-input v-model="form.created_at" :maxlength="42" placeholder="请输入内容" />
                </div>
              </li>
              <li class="list-item">
                <div class="tip">
                  <span class="must">*</span> 充值凭证：
                </div>
                <div class="detail">
                  <ul class="img-list">
                    <li
                      v-for="(item, index) in form.recharge_picture"
                      :key="index"
                      class="img-item"
                    >
                      <img v-if="item" :src="common.img_url+item" alt class="img" />
                    </li>
                  </ul>
                  <!--                <img :src="form.recharge_picture" alt style="width:100px;">-->
                </div>
              </li>
              <li class="list-item">
                <div class="tip">
                  <span class="must">*</span> 充值说明：
                </div>
                <div class="detail">
                  <el-input v-model="form.remark" :maxlength="42" placeholder="请输入内容" />
                </div>
              </li>
            </ul>
          </div>
        </el-tab-pane>
        <el-tab-pane label="发票信息" name="second">
          <div class="section">
            <h2 class="title">发票信息</h2>
            <ul class="info">
              <li class="list-item">
                <div class="tip">
                  <span class="must">*</span> 是否需要发票：
                </div>
                <div class="detail">
                  <el-radio-group v-model="form.is_invoice">
                    <el-radio :label="0">需要</el-radio>
                    <el-radio :label="1">不需要</el-radio>
                  </el-radio-group>
                </div>
              </li>
              <li class="list-item" v-if="form.is_invoice == 0">
                <div class="tip">
                  <span class="must">*</span> 发票类型
                </div>
                <div class="detail">
                  <el-select v-model="form.invoiceList.invoice_type" placeholder="请选择">
                    <el-option
                      v-for="item in invoiceType"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    />
                  </el-select>
                </div>
              </li>
              <li class="list-item" v-if="form.is_invoice == 0">
                <div class="tip">
                  <span class="must">*</span> 单位名称：
                </div>
                <div class="detail">
                  <el-input
                    v-model="form.invoiceList.company_name"
                    :maxlength="42"
                    placeholder="请输入内容"
                  />
                </div>
              </li>
              <li class="list-item" v-if="form.is_invoice == 0">
                <div class="tip">
                  <span class="must">*</span> 纳税识别号：
                </div>
                <div class="detail">
                  <el-input v-model="form.invoiceList.tax_num" :maxlength="42" placeholder="请输入内容" />
                </div>
              </li>
              <li class="list-item" v-if="form.is_invoice == 0">
                <div class="tip">
                  <span class="must">*</span> 注册地址：
                </div>
                <div class="detail">
                  <el-input
                    v-model="form.invoiceList.registered_address"
                    :maxlength="42"
                    placeholder="请输入内容"
                  />
                </div>
              </li>
              <li class="list-item" v-if="form.is_invoice == 0">
                <div class="tip">
                  <span class="must">*</span> 注册电话：
                </div>
                <div class="detail">
                  <el-input
                    v-model="form.invoiceList.registered_phone"
                    :maxlength="42"
                    placeholder="请输入内容"
                  />
                </div>
              </li>
              <li class="list-item" v-if="form.is_invoice == 0">
                <div class="tip">
                  <span class="must">*</span> 开户账户：
                </div>
                <div class="detail">
                  <el-input
                    v-model="form.invoiceList.account_name"
                    :maxlength="42"
                    placeholder="请输入内容"
                  />
                </div>
              </li>
              <li class="list-item" v-if="form.is_invoice == 0">
                <div class="tip">
                  <span class="must">*</span> 开户银行：
                </div>
                <div class="detail">
                  <el-input
                    v-model="form.invoiceList.account_bank"
                    :maxlength="42"
                    placeholder="请输入内容"
                  />
                </div>
              </li>
              <li class="list-item" v-if="form.is_invoice == 0">
                <div class="tip">
                  <span class="must">*</span> 收票人姓名：
                </div>
                <div class="detail">
                  <el-input
                    v-model="form.invoiceList.taker_name"
                    :maxlength="42"
                    placeholder="请输入内容"
                  />
                </div>
              </li>
              <li class="list-item" v-if="form.is_invoice == 0">
                <div class="tip">
                  <span class="must">*</span> 收票人电话：
                </div>
                <div class="detail">
                  <el-input
                    v-model="form.invoiceList.taker_phone"
                    :maxlength="42"
                    placeholder="请输入内容"
                  />
                </div>
              </li>
              <li class="list-item" v-if="form.is_invoice == 0">
                <div class="tip">
                  <span class="must">*</span> 发票邮寄地址：
                </div>
                <div class="detail">
                  <el-input v-model="form.invoiceList.mail" :maxlength="42" placeholder="请输入内容" />
                </div>
              </li>
              <li class="list-item" v-if="form.is_invoice == 0">
                <div class="tip">
                  <span class="must">*</span> 详细地址：
                </div>
                <div class="detail">
                  <el-input
                    v-model="form.invoiceList.mail_address"
                    :maxlength="42"
                    placeholder="请输入内容"
                  />
                </div>
              </li>
            </ul>
          </div>
        </el-tab-pane>
      </el-tabs>
    </el-form>
  </div>
</template>

<script>
import { cashShow } from "@/api/cashOut";
import { rechargeShow } from "../../api/NewRetailSystem";
export default {
  name: "Detail",
  data() {
    return {
      activeName: "first",
      invoiceType: [
        {
          id: 1,
          name: "增值税普通发票",
        },
        {
          id: 2,
          name: "增值税专用发票",
        },
      ],
      form: {
        id: "", //	记录id
        hospital_id: "", //		机构id
        bank_id: "", //		银行卡id
        bank_type: "", //		开户类型 1对公 2对私
        bank_number: "", //		银行卡号
        bank_name: "", //		开户行名称
        bank_user_name: "", //		持卡人名称
        money: "", //		充值金额
        remark: "", //		充值说明
        created_at: "", //	充值时间
        recharge_picture: "", //		充值凭证
        is_invoice: "", //		是否需要发票：0-需要，1-不需要
        invoiceList: {
          invoice_type: "", //		发票类型：1-增值税普通发票，2-增值税专用发票
          company_name: "", //	单位名称
          tax_num: "", //		纳税识别号
          registered_address: "", //		注册地址
          registered_phone: "", //		注册电话
          account_name: "", //		开户账户
          account_bank: "", //		开户银行
          taker_name: "", //		收票人姓名
          taker_phone: "", //		收票人电话
          mail_province: "", //		发票邮寄地址-省
          mail_city: "", //		发票邮寄地址-市
          mail_address: "", //
          mail: "", //前端自定义发票地址  用于拼接
        }, //		发票信息
      },
      bankCardList: [],
      rules: {},
      type: "",
    };
  },

  components: {},

  mounted() {
    this.type = this.$route.query.type;
    if (this.$route.query.type == "detail") {
      // this.$route.meta.title = "查看详情";
      this.getDetails(this.$route.query.id);
      // this.isDisabled = true;
    }
  },

  methods: {
    async getDetails(id) {
      let data = { id };
      let res = await rechargeShow(data);
      console.log("2222res", res);
      if (res.data.status == 0) {
        let resData = res.data.data;
        this.form = resData;
        console.log(" this.form.invoiceList", this.form.invoiceList);
        if (this.form.invoiceList != undefined) {
          this.form.invoiceList.mail =
            this.form.invoiceList.mail_province +
            this.form.invoiceList.mail_city;
        }
        this.form.recharge_picture = this.form.recharge_picture.split(";");
        console.log("form.recharge_picture", this.form.recharge_picture);
      } else {
        this.errorStatus(res.data.message);
      }
    },
    // 失败状态弹窗
    errorStatus(txt) {
      this.eleMsg(txt, "error");
    },
    // 成功状态弹窗
    warnStatus(txt, status) {
      this.eleMsg(txt, status);
    },
    // 弹窗组件
    eleMsg(txt, status) {
      this.$message({
        showClose: true,
        message: txt,
        type: status,
      });
    },
  },
};
</script>
<style  lang="scss" scoped>
.container {
  padding: 30px;
  .section {
    .title {
      width: 130px;
      height: 30px;
      line-height: 30px;
      text-align: center;
      margin-bottom: 20px;
    }
    .info {
      margin-left: 40px;
      .list-item {
        margin-bottom: 20px;
        .tip {
          font-size: 14px;
          display: inline-block;
          vertical-align: middle;
          width: 150px;
          text-align: right;
          .msk {
            font-size: 10px;
            color: #666;
            margin-right: 20px;
            margin-top: 10px;
          }
          .must {
            display: inline-block;
            vertical-align: middle;
            color: #ff3040;
          }
        }
        .detail {
          color: #666;
          min-width: 350px;
          font-size: 16px;
          display: inline-block;
          vertical-align: middle;
          .el-select {
            display: block !important;
          }
          .img-list {
            display: inline-block;
            vertical-align: top;
            .img-item {
              width: 600px;
              // height: 100%;
              border: 1px solid #ccc;
              display: inline-block;
              vertical-align: middle;
              overflow: hidden;
              margin-right: 10px;
              position: relative;
              .img {
                width: 100%;
              }
              .del-btn {
                width: 100%;
                height: 100%;
                background-color: rgba(0, 0, 0, 0.3);
                color: #fff;
                line-height: 150px;
                text-align: center;
                font-size: 40px;
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                cursor: pointer;
                display: none;
              }
              &:hover {
                .del-btn {
                  display: block;
                }
              }
            }
          }
          .upload-btn {
            width: 150px;
            height: 150px;
            display: inline-block;
            vertical-align: middle;
            position: relative;
            .el-icon-plus {
              width: 150px;
              height: 150px;
              display: block;
              position: relative;
              &::before {
                font-size: 30px;
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
              }
            }
          }
          &.project_detail {
            vertical-align: top;
          }

          .rule {
            display: flex;
            align-items: center;
            justify-content: space-around;
            flex-direction: row;
          }
        }
      }
    }
  }
  .sub-btn {
    .el-button {
      margin: 80px auto 20px auto;
      display: block;
    }
  }

  .form-control {
    width: 100%;
    padding-right: 6px;
    min-height: 300px;
    -webkit-overflow-scrolling: touch;
    resize: none;
    outline: 0 none;
    margin-top: 12px;
    font-size: 14px;
    /*font-family: MicrosoftYaHei;*/
    color: rgba(13, 20, 30, 1);
    line-height: 19px;
    opacity: 0.6;
  }
}
</style>
